package com.gxw.www.myapp.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPreferencesUtil {

	private Context context;

	/**
	 * 构造函数
	 * 
	 * @param context
	 *            ：传递过来的上下文对象
	 */
	public SharedPreferencesUtil(Context context) {
		this.context = context;
	}

	/**
	 * 保存操作
	 * 
	 * @param fileName
	 *            ：文件名称
	 * @param mode
	 *            ：文件模式
	 * @param userName
	 *            ：用户名
	 * @param userPass
	 *            ：密码
	 */
	public void save(String fileName, int mode, String userName, String userPass) {
		SharedPreferences sp = context.getSharedPreferences(fileName, mode);
		Editor editor = sp.edit();
		editor.putString("userName", userName);
		editor.putString("userPass", userPass);
		editor.commit();
	}

	public void save2(String fileName, int mode, String ip, String userName,
			String userPass, int i, boolean isRememberPwd) {
		SharedPreferences sp = context.getSharedPreferences(fileName, mode);
		Editor editor = sp.edit();
		editor.putString("ip", ip);
		editor.putString("userName", userName);
		editor.putInt("server", i);
		editor.putString("userPass", userPass);
		editor.putBoolean("isRememberPsw", isRememberPwd);
		editor.commit();
	}

}
